home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 1a / demos / habba5.c next >
Encoding:
C/C++ Source or Header  |  1985-05-29  |  2.9 KB  |  143 lines

  1. /* ST Color Palette by Tom Hudson
  2.    Habba 'C' modifications by John Kurvink */
  3.  
  4. /* main changes were to demote int to short and adding CONIN and
  5.    char_input_status functions since I they replace the BCONSTAT
  6.    and BCONIN inthe original program(with the hippo 'C' they would
  7.    work corectly therfore program would loop forever */
  8.  
  9. /* compile the program and then type ld -S st512.o color.o<ret>
  10.    Then rename the newly created a.prg to whatever.TOS or it
  11.    will lock up when you move the mouse */
  12.  
  13. #include <aes.h>
  14. #include <vdi.h>
  15. extern go();
  16. extern stop();
  17. extern short ctable[512];
  18.  
  19. short contrl[12],intin[128],ptsin[128],
  20.       intout[128],ptsout[128];
  21.  
  22. short handle,chstat;
  23.  
  24. main()
  25. {
  26.  
  27. short i,j,dum,l_intin[11],l_out[57],
  28.       r,g,b,rx,gx,bx,cx,x,y,wchar,
  29.       gr_1,gr_2,gr_3,gr_4,l_ptsin[20],
  30.       oldpal[16],box[4],rgb[3],
  31.       mousex,mousey;
  32. int regval;
  33.  
  34. char lastr = -1, lastg = -1, lastb = -1;
  35.  
  36. static short cofset[8] =
  37. {
  38. 2,3,6,4,7,5,8,9
  39. };
  40.  
  41. static char redval[2] = {0,0};
  42. static char grnval[2] = {0,0};
  43. static char bluval[2] = {0,0};
  44.  
  45. appl_init();
  46.  
  47. handle=graf_handle(&gr_1,&gr_2,&gr_3,&gr_4);
  48.  
  49. l_intin[0] = 1;
  50. for (i=1;i<10; i++)
  51.     l_intin[i] = 1;
  52. l_intin[10] = 2;
  53. v_opnvwk(l_intin,&handle,l_out);
  54. v_hide_c(handle);
  55. v_clrwk(handle);
  56.  
  57. for (i=0;i<16;i++)
  58.     oldpal[i] = setcolor(i,-1);
  59.  
  60. cx=0;
  61.  
  62. for (rx=0;rx<8; rx++)
  63.  {
  64.   for(gx=0;gx<8;gx++)
  65.   {
  66.   for(bx=0;bx<8;bx++,cx++)
  67.    {
  68.     regval=0x0000f888 + (rx * 256) + (gx * 16) +bx;
  69.     ctable[cx]=regval & 0xffff;
  70.    }
  71.   }
  72.  }
  73.  
  74. vsf_interior(handle,1);
  75. for (x=0,cx=0;x<319;x+=40,cx++)
  76.  {
  77.   vsf_color(handle,cofset[cx]);
  78.   for (y=1;y<192;y+=3)
  79.     {
  80.      box[0]=x;
  81.      box[1]=y;
  82.      box[2]=x+38;
  83.      box[3]=y+1;
  84.      v_bar(handle,box);
  85.      }
  86.    }
  87.  
  88. rgb[0]=1000; rgb[1]=1000; rgb[2]=1000;
  89. vs_color(handle,1,rgb);
  90. rgb[0]=1000;rgb[1]=0;rgb[2]=0;
  91. vs_color(handle,11,rgb);
  92. rgb[0]=0;rgb[1]=1000;rgb[2]=0;
  93. vs_color(handle,14,rgb);
  94. rgb[0]=0;rgb[1]=0;rgb[2]=1000;
  95. vs_color(handle,12,rgb);
  96.  
  97. vst_color(handle,10);
  98. v_gtext(handle,40,199,"ATARI 520ST COLOR PALETTE");
  99. graf_mouse(0,&dum);
  100. v_show_c(handle,0);
  101.  
  102. go();
  103.  
  104. wchar=0;
  105. while(wchar != 32)
  106.  {
  107.   chstat=char_input_status(2);
  108.   if(chstat !=0)
  109.     wchar=conin(2);
  110.  
  111.   vq_mouse(handle,&dum,&mousex,&mousey);
  112.  
  113.   if(mousey < 192)
  114.    {
  115.     redval[0]=mousey / 24 + 48;
  116.     grnval[0]=((mousey/3) & 0x0007) + 48;
  117.     bluval[0]=mousex / 40 + 48;
  118.     if((lastr != redval[0]) || (lastg != grnval[0]) || (lastb != bluval[0]))
  119.       {
  120.         v_hide_c(handle);
  121.         vst_color(handle,11);
  122.         v_gtext(handle,256,199,redval);
  123.         vst_color(handle,14);
  124.         v_gtext(handle,264,199,grnval);
  125.         vst_color(handle,12);
  126.         v_gtext(handle,272,199,bluval);
  127.         v_show_c(handle,0);
  128.         lastr=redval[0];
  129.         lastg=grnval[0];
  130.         lastb=bluval[0];
  131.       }
  132.      }
  133.    }
  134.  
  135. stop();
  136. setpallete(oldpal);
  137.  
  138. v_clsvwk(handle);
  139.  
  140. appl_exit();
  141.  
  142. }
  143. əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə